package edu.sdjzu.exam.mapper.group;

import edu.sdjzu.exam.domain.group.UserGroupMember;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserGroupMemberMapper {

    @Insert("INSERT INTO User_Group_Members (group_id, user_id) VALUES (#{groupId}, #{userId})")
    void insertUserGroupMember(UserGroupMember userGroupMember);

    @Select("SELECT * FROM User_Group_Members WHERE group_id = #{groupId}")
    List<UserGroupMember> selectMembersByGroupId(Long groupId);

    @Delete("DELETE FROM User_Group_Members WHERE group_id = #{groupId} AND user_id = #{userId}")
    void deleteUserGroupMember(@Param("groupId") Long groupId, @Param("userId") Long userId);

    @Select("SELECT * FROM User_Group_Members WHERE group_id = #{groupId} AND user_id = #{userId}")
    UserGroupMember selectUserGroupMember(@Param("groupId") Long groupId, @Param("userId") Long userId);

    @Delete("DELETE FROM User_Group_Members WHERE group_id = #{groupId}")
    void deleteMembersByGroupId(Long groupId);
}